package com.insurance.controller;

import com.insurance.domain.ResponseResult;
import com.insurance.domain.entity.Case;
import com.insurance.domain.entity.Customer;
import com.insurance.domain.enums.AppHttpCodeEnum;
import com.insurance.domain.vo.CasePageVo;
import com.insurance.domain.vo.CustomerPageVo;
import com.insurance.service.CaseService;
import com.insurance.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.aspectj.apache.bcel.generic.ClassGen;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author qcjstudy
 * @create 2023-04-22 9:55
 */
@RestController
@RequestMapping("/api/case")
@Api(tags = "病历管理",description = "病历管理相关接口")
public class CaseController {

    @Autowired
    private CaseService caseService;

    private CasePageVo casePageVo;

    @PostMapping("/list")
    @ApiOperation(value = "病历列表",notes = "分页查询所有病历信息")
    public ResponseResult list(@RequestBody CasePageVo casePageVo){
        this.casePageVo = casePageVo;
        System.out.println(casePageVo);
        return caseService.listByPage(casePageVo);
    }

    @PostMapping()
    public ResponseResult add(@RequestBody Case case1){
        return caseService.addCase(case1);
    }

    @PutMapping("/update")
    public ResponseResult update(@RequestBody Case case1){
        return caseService.updateCase(case1);
    }

    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Long id){
        if(caseService.removeById(id)){
            return ResponseResult.okResult();
        }
        return ResponseResult.errorResult(AppHttpCodeEnum.DELETE_FAILED);
    }

}
